var FormValidation = function () {


    return {
        //main function to initiate the module
        init: function () {

            // for more info visit the official plugin documentation: 
            // http://docs.jquery.com/Plugins/Validation

            var form1 = $('#form_sample_1');
            var error1 = $('.alert-error', form1);
            var success1 = $('.alert-success', form1);
            var reload = $('.alert-reload');//获取加载div对象
            form1.validate({
                errorElement: 'span', //default input error message container
                errorClass: 'help-inline', // default input error message class
                focusInvalid: false, // do not focus the last invalid input
                ignore: "",
                rules: {
                    cardNumber: {   //身份证号
                        minlength: 18,
                        maxlength: 18,
                        required: true
                    },
                    phoneNumber: { //手机号码
                        minlength: 11,
                        maxlength:11,
                        required: true
                    },
        	        vihicleType:{ //车辆类型
        	        	required: true
        	        },
        	        vihicleNumber:{ //车辆号码
        	        	required: true
        	        },
        	        vihicleIdentifyNumber:{  //车识别号
        	        	required: true
        	        },
        	        archiveNumber:{  //档案编号
        	        	required: true
        	        },
                    name: {  //车主姓名
                        minlength: 2,
                        required: true
                    },
                    email: {   //邮箱
                        required: true,
                        email: true
                    }
                },

                invalidHandler: function (event, validator) { //display error alert on form submit              
                    success1.hide();
                    reload.hide();
                    error1.show();
                    App.scrollTo(error1, -200);
                },

                highlight: function (element) { // hightlight error inputs
                    $(element)
                        .closest('.help-inline').removeClass('ok'); // display OK icon
                    $(element)
                        .closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group
                },

                unhighlight: function (element) { // revert the change dony by hightlight
                    $(element)
                        .closest('.control-group').removeClass('error'); // set error class to the control group
                },

                success: function (label) {
                    label
                        .addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon
                    .closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group
                },

                submitHandler: function (form) {
                    success1.show();
                    reload.hide();
                    document.forms[0].submit();
                    error1.hide();
                }
            });

            //Sample 2
           
        }

    };

}();